require(['jquery', 'cookie', 'app', "lay"], function ($) {
    require(['vue'], function (Vue) {
        var dic = new Vue({
            el: ".vue-box"
            , data: {
                where: {},
                thatUser: {},
                that: {
                    money: ""
                },
                userInfo: {},
                pay: [],
                tx: {}
            }
            , created: function () {
                this.userInfo = JSON.parse(localStorage.getItem("userInfo"));
                this.tx = playGet("/v1/api/diction/TX").data;
                this.loadPage();
            }
            , methods: {
                loadPage: function () {
                    load();
                    var toolbar = [];
                    var tool = [];
                    toolbar.push({
                        "clas": "layui-btn-danger",
                        "eve": "N",
                        "tit": "拒绝",
                        "fnc": function (data) {
                            if (data.length <= 0) {
                                alr("请选择一条记录");
                                return;
                            }
                            var jon = data[0];
                            var re = playPost("v1/api/apply/status/" + jon.id, {status: false}, "");
                            alr(re.msg);
                            reload();
                        }
                    });
                    toolbar.push({
                        "clas": "layui-btn-danger",
                        "eve": "UPDATE1",
                        "tit": "通过",
                        "fnc": function (data) {
                            if (data.length <= 0) {
                                alr("请选择一条记录");
                                return;
                            }
                            dic.thatUser = data[0];
                            var jon = data[0];
                            var re = playPost("v1/api/apply/status/" + jon.id, {status: true}, "");
                            alr(re["msg"]);
                            reload();
                        }
                    });
                    bspVIEW($("#authoritiesTable"), "/v1/api/apply/all", [
                        {type: 'radio',width: 150},
                        {type: 'numbers'},
                        {field: 'id', title: '支付单ID', minWidth: 80},
                        {
                            templet: function (d) {
                                return d.users.name;
                            }, title: '用户名称', minWidth: 80
                        },
                        {
                            templet: function (d) {
                                return d.userDeposit.people;
                            }, title: '收款人', minWidth: 80
                        },
                        {
                            templet: function (d) {
                                if(d.userDeposit.type.display=='银行卡'){
                                    return d.userDeposit.no;
                                }else{
                                    return "<a target='_blank' href='"+d.userDeposit.note+"'>"+d.userDeposit.note+"</a>";
                                }
                            }, title: '收款账号(点击查看)', minWidth: 120
                        },
                        {
                            templet: function (d) {
                                return d.userDeposit.type.display;
                            }, title: '收款方式', minWidth: 80
                        },
                        {
                            templet: function (d) {
                                return d.money+d.fastMoney;
                            }, title: '提现金额', minWidth: 80
                        },
                        {field: 'money', title: '实付金额', minWidth: 80},
                        {field: 'fastMoney', title: '提现手续费', minWidth: 80},
                        {
                            templet: function (d) {
                                if (d.type.display == '申请中') {
                                    return "<p style='background: red;color: white'>" + d.type.display;
                                    +"</p>";
                                }
                                if (d.type.display == '拒绝') {
                                    return "<p style='background: blue;color: white'>" + d.type.display;
                                    +"</p>";
                                }
                                if (d.type.display == '付款审核中') {
                                    return "<p style='background: black;color: white'>" + d.type.display;
                                    +"</p>";
                                }
                                if (d.type.display == '已支付') {
                                    return "<p style='background: white'>" + d.type.display;
                                    +"</p>";
                                }
                            },
                            align: 'center',
                            width: 120,
                            title: '支付状态'
                            , minWidth: 120
                        },
                        {field: 'createTime', title: '提现时间', minWidth: 80},
                    ], {common: this.where}, toolbar, tool, function (res, curr, count) {

                    });
                },
                seachs: function () {
                    this.where = fromName($(".el-form"));
                    this.loadPage();
                },
                refer: function () {

                },
                openAdd: function () {
                    alrYN($("#admins"), function () {
                        var user = dic.thatUser;
                        var re = playPut("v1/api/users/blance", {
                            "applyId": user['id'],
                            "type": "INS"
                        }, "");
                        alr(re["msg"]);
                    }, function () {

                    }, function () {

                    }, "请输入金额", 1, ["600px", "350px"]);
                }
            }
        });
    })
});